﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MvcTricks.RoundTripModelBinding.Serialization;

namespace MvcTricks.RoundTripModelBinding.Testing
{
    [TestClass]
    public class DateTimeConverterTests
    {

        [TestMethod]
        public void Can_Serialize_And_Deserialize_Nullable_DateTime_Min_Value()
        {
            DateTime? minValue = DateTime.MinValue;
            var serialized = ModelData.Serialize(minValue);
            Assert.AreEqual(minValue, ModelData.Deserialize<DateTime?>(serialized));
        }

        [TestMethod]
        public void Can_Serialize_And_Deserialize_Nullable_DateTime_Max_Value()
        {
            DateTime? maxValue = DateTime.MaxValue;
            var serialized = ModelData.Serialize(maxValue);
            Assert.AreEqual(maxValue, ModelData.Deserialize<DateTime?>(serialized));
        }

        [TestMethod]
        public void Can_Serialize_And_Deserialize_Nullable_DateTime_Null_Value()
        {
            DateTime? nullValue = null;
            var serialized = ModelData.Serialize(nullValue);
            Assert.AreEqual(nullValue, ModelData.Deserialize<DateTime?>(serialized));
        }

        [TestMethod]
        public void Can_Serialize_And_Deserialize_DateTime_Min_Value()
        {
            DateTime minValue = DateTime.MinValue;
            var serialized = ModelData.Serialize(minValue);
            Assert.AreEqual(minValue, ModelData.Deserialize<DateTime?>(serialized));
        }

        [TestMethod]
        public void Can_Serialize_And_Deserialize_DateTime_Max_Value()
        {
            DateTime maxValue = DateTime.MaxValue;
            var serialized = ModelData.Serialize(maxValue);
            Assert.AreEqual(maxValue, ModelData.Deserialize<DateTime?>(serialized));
        }

    }
}
